package com.yang.Thread;

/**
 * @Description: TODO
 * @Author: YangTing
 * @Date: 2024-05-09 12:20
 */

public class EvenNumberTest {
    public static void main(String[] args) {
        PrintNumber printNumber = new PrintNumber("杨汀");
        printNumber.start();
        Thread.currentThread().setName("我不是线程");
        for (int i = 0; i < 100 ; i++){
            if(i % 2 == 0){
                System.out.println(Thread.currentThread().getName() + " = " + i);
            }
        }
    }
}
class PrintNumber extends Thread{
    PrintNumber(String name){
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i < 100 ; i++){
            if(i % 2 == 0){
//                try {
//                    Thread.sleep(10000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
                System.out.println(Thread.currentThread().getName() + " = " + i);
            }
            if(i % 10 == 0){
                Thread.yield();
            }
        }
    }
}
